clear

import delimited "data/two_arm_simulated_data.csv", case(preserve) clear


bysort Z: egen group_mean = mean(Y)
bysort Z: egen group_sd = sd(Y)
bysort Z: egen group_N = count(Y)
gen group_se = group_sd / sqrt(group_N)
gen conf_high = group_mean + 1.96*group_se
gen conf_low = group_mean - 1.96*group_se
gen Z_jitter = Z + runiform(-0.05, 0.05)
gen Y_jitter = Y + runiform(-0.05, 0.05)


#delimit ;
twoway 
	scatter Y_jitter Z_jitter, mcolor(%20) msize(1) || 
	scatter group_mean Z, msize(2) mcolor(red) || 
	rcap conf_high conf_low  Z, color(red);

